package br.com.insight.consultoria.negocio.bo;

import java.util.List;

import br.com.insight.consultoria.entity.Usuario;
import br.com.insight.consultoria.entity.Vaga;
import br.com.insight.consultoria.erro.exception.InsightConstants;
import br.com.insight.consultoria.erro.exception.InsightException;
import br.com.insight.consultoria.erro.exception.SistemaException;
import br.com.insight.consultoria.integracao.dao.interfacedao.VagaDAO;
import br.com.insight.consultoria.negocio.bo.interfacebo.VagaBO;

public class VagaImpBO implements VagaBO{
	
	
	private VagaDAO vagaDAO;
	
	@Override
	public void inserir(Vaga vaga) throws InsightException {
		
		try{
		
		getVagaDAO().inserir(vaga);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	@Override
	public void alterar(Vaga vaga) throws InsightException {
		
		try{

		getVagaDAO().alterar(vaga);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	@Override
	public void excluir(Vaga vaga) throws InsightException {
		
		try{
		
		getVagaDAO().excluir(vaga);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	@Override
	public Vaga getVaga(Long id) throws InsightException {
		
		Vaga vaga=null;
		
		try{
		
			vaga=getVagaDAO().getVaga(id);
			
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
		return vaga;
	}
	
	@Override
	public List<Vaga> pesquisar(Usuario usuario) throws InsightException {
		
		List<Vaga> vagas=null;
		
		try{
		
			vagas=getVagaDAO().pesquisar(usuario);
			
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
			
		return vagas;
	}
	
	@Override
	public List<Vaga> listaVagas() throws InsightException {
		
		List<Vaga> listaVagas=null;
		
		try{
		
			listaVagas=getVagaDAO().listaVagas();
			
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
			
		return listaVagas;
	}

	
	public VagaDAO getVagaDAO() {
		return vagaDAO;
	}

	public void setVagaDAO(VagaDAO vagaDAO) {
		this.vagaDAO = vagaDAO;
	}
	
}
